package com.weilus.es;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.RestClients;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate;

@Configuration
public class ElasticSearchConfig {

    @Bean
    ReactiveElasticsearchTemplate reactiveElasticsearchTemplate(ReactiveElasticsearchClient client){
        return new ReactiveElasticsearchTemplate(client);
    }

    @Bean
    ElasticsearchRestTemplate restTemplate(ClientConfiguration clientConfiguration){
        return new ElasticsearchRestTemplate(RestClients.create(clientConfiguration).rest());
    }
}
